package org.opicasso.cheese.ui;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.apache.wicket.Application;
import org.apache.wicket.Request;
import org.apache.wicket.Response;
import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebApplication;
import org.hibernate.SessionFactory;
import org.opicasso.cheese.domain.Cheese;
import org.opicasso.cheese.persistence.HibernateUtil;
import org.opicasso.cheese.ui.pages.HomePage;

/**
 * Application object for your web application. If you want to run this
 * application without deploying, run the Start class.
 * 
 * @see wicket.myproject.Start#main(String[])
 */
public class CheeseApplication extends WebApplication {
	private static final List<Cheese> cheeses = Arrays
			.asList(
					new Cheese(
							"Gouda",
							"Gouda is a yellowish Dutch cheese named after the city of Gouda, but the term Gouda is now a generic name, and not restricted to cheese of Dutch origin. Without any spices added, this cheese has a mild, creamy taste that has not changed since the Gouda cheese was first made several centuries ago.",
							1.65),
					new Cheese(
							"Edam",
							"Edam (Dutch Edammer) is a Dutch cheese that is traditionally sold as spheres with pale yellow interior and a coat of paraffin. Its Spanish name is queso de bola, literally \"ball cheese.\" It is named after the town of Edam in the province of North Holland,[1] where the cheese is coated for export and for tourist high season. Edam which has aged for at least 17 weeks is coated with black wax, rather than the usual red or yellow.",
							1.05),
					new Cheese(
							"Maasdam",
							"Maasdam cheese is a Dutch cheese in a Swiss-style. Made from cow's milk, it is aged for at least 4 weeks. It ripens faster than other Dutch cheeses. Maasdam has internal holes from the ripening process, and a smooth yellow rind. Sometimes it is waxed like Gouda. The cheese was created to compete with the popular Swiss Emmental by being less expensive and quicker to produce. In the process of making a cheese with the same general components as Swiss cheeses, the Dutch ended up with a cheese that is nutty and sweet, but softer than Emmental due to a higher moisture content.",
							2.35),
					new Cheese(
							"Brie",
							"Brie is a soft cows' cheese named after Brie, the French province in which it originated (roughly corresponding to the modern département of Seine-et-Marne). It is pale in color with a slight greyish tinge under crusty white mold; very soft and savory with a hint of ammonia. The white moldy rind is edible, and is not intended to be separated from the cheese during consumption.",
							3.15),
					new Cheese(
							"Buxton Blue",
							"Buxton Blue cheese is an English blue cheese that is a close relative of Blue Stilton. It is made from cow's milk and is lightly veined with a deep russet colouring. It is usually made in a cylindrical shape. This cheese is complimented with a chilled glass of sweet dessert wine or ruby port. Its production in Europe is regulated under Protected designation of origin laws, having PDO status, and can only be made in and around Buxton from milk originating in Derbyshire, Nottinghamshire or Staffordshire.",
							0.99),
					new Cheese(
							"Parmesan",
							"Parmigiano-Reggiano is a hard, fat granular cheese, cooked but not pressed, named after the producing areas of Parma, Reggio Emilia, Modena, Bologna, in Emilia-Romagna, and Mantova, in Lombardy, Italy.",
							1.99),
					new Cheese(
							"Cheddar",
							"Cheddar cheese is a relatively hard, pale yellow to off-white, and sometimes sharp-tasting cheese originating in the English village of Cheddar, in Somerset. [1] Cheddar cheese is the most popular cheese in the United Kingdom, accounting for 51% of the country's £1.9 billion annual cheese market.",
							2.95),
					new Cheese(
							"Roquefort",
							"Roquefort, is a sheep milk blue cheese from the south of France, and together with Bleu d'Auvergne, Stilton and Gorgonzola is one of the world's best-known blue cheeses. Though similar cheeses are produced elsewhere, European law dictates that only those cheeses aged in the natural Combalou caves of Roquefort-sur-Soulzon may bear the name Roquefort, as it is a recognised geographical indication, or has a protected designation of origin. Roquefort is sometimes known as the \"King of Cheeses\", a distinction that is also used for the Italian Parmigiano Reggiano, the French Brie de Meaux & Époisses de Bourgogne, and the English Stilton[",
							1.67),
					new Cheese(
							"Boursin",
							"Boursin cheese was first produced in 1957 by François Boursin in Normandy. Boursin is a trademark – Boursin cheese was at one time produced exclusively in Croisy-sur-Eure, France, by the Boursin company, a subsidiary of Group Bel, which purchased Boursin on 2007-11-05 for 400 million euros[1]. The cheese is also produced in the United States for North American distribution by Unilever.",
							1.33),
					new Cheese(
							"Camembert",
							"Camembert is made from unpasteurized cow's milk, and is ripened by the moulds Penicillium candida and Penicillium camemberti for at least three weeks. It is produced in small rounds, about 250 grams in weight, which are then typically wrapped in paper and packaged in thin wooden boxes.",
							1.69),
					new Cheese(
							"Emmental",
							"Emmental, Emmentaler, Emmenthal, or Emmenthaler is a cheese from Switzerland. It is sometimes known as Swiss cheese in North America, Australia and New Zealand, although Swiss cheese does not always imply Emmental.",
							2.39),
					new Cheese(
							"Reblochon",
							"Reblochon is a French cheese from the Alps region of Savoie and has been granted the AOC title. Reblochon was first produced in the Thônes and Arly valleys, in the Aravis massif. Thônes remains the centre of Reblochon production, the cheeses are still made in the local cooperatives. Until 1964 Reblochon was also produced in Italian areas of the Alps. Subsequently the Italian cheese has been sold in declining quantities under such names as Rebruchon and Reblò alpino.",
							2.99));

	private final SessionFactory sessionFactory = HibernateUtil
			.getSessionFactory();

	public SessionFactory getHibernateSessionFactory() {
		return sessionFactory;
	}

	/**
	 * @see wicket.Application#getHomePage()
	 */
	public Class<HomePage> getHomePage() {
		return HomePage.class;
	}

	public List<Cheese> getCheeses() {
		return Collections.unmodifiableList(cheeses);
	}

	@Override
	public Session newSession(Request request, Response response) {
		return new CheeseSession(request);
	}

	public static CheeseApplication get() {
		return (CheeseApplication) Application.get();
	}

}
